﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entity;
using Business;
namespace OnlineRecruit
{
    public partial class zhiwei : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string keyword = txtKeyword.Text.Trim();  // 获取职位关键词
            string location = txtLocation.Text.Trim(); // 获取工作地点

            // 调用方法查询职位数据（模拟）
            List<Job> jobs = SearchJobs(keyword, location);

            // 判断是否找到匹配的职位
            if (jobs.Count > 0)
            {
                // 如果找到职位，将结果绑定到Repeater控件
                rptJobs.DataSource = jobs;
                rptJobs.DataBind();
                lblNoResults.Visible = false; // 隐藏未找到职位的提示
                searchResults.Visible = true; // 显示搜索结果区域
            }
            else
            {
                // 如果没有找到职位，显示未找到的提示
                lblNoResults.Visible = true;
                searchResults.Visible = false;
            }
        }

        // 模拟职位搜索（你可以根据需求从数据库或其他源查询数据）
        public  SearchJobs(string keyword, string location)
        {
            // 示例职位数据
            var allJobs = new List<Job>
        {
            new Job { Title = "前端开发工程师", Company = "ABC科技公司", Location = "北京", Type = "全职", Salary = "15K-20K", Description = "负责前端开发工作，要求掌握HTML、CSS、JavaScript等技术。" },
            new Job { Title = "后端开发工程师", Company = "XYZ网络公司", Location = "上海", Type = "全职", Salary = "18K-25K", Description = "负责后端开发工作，要求掌握C#、ASP.NET等技术。" },
            new Job { Title = "UI设计师", Company = "创意设计公司", Location = "深圳", Type = "兼职", Salary = "10K-12K", Description = "负责UI设计，要求熟练使用Sketch、Photoshop等设计工具。" }
        };

            // 根据关键词和地点过滤职位数据
            var result = allJobs.FindAll(job =>
                (string.IsNullOrEmpty(keyword) || job.Title.Contains(keyword)) &&
                (string.IsNullOrEmpty(location) || job.Location.Contains(location))
            );

            return result;
        }
    }
}
